import { CriterionI, OrderI, ProjectionI, TurnablePage } from "../criteria-page";
import { Field } from "../field-entity";
import { Component } from "react";
import { RpcResult } from "../rpc-result";

export interface ListI extends Component {
  refreshList: () => Promise<RpcResult>;
  loadCriterions: () => CriterionI[];
  operations: Operation[];
  // 3. infos
  getInfos: () => ListInfo;
  allDatas: any[];
  selectedStatus: boolean[];
  fields: Field[];
}
export interface ListInfo {
  rootEntity: string;
  criterions: CriterionI[];
  projections: ProjectionI[];
  orders: OrderI[];
  page: TurnablePage;
  keyword: string;
}
// it can be batch operation if Function.length === 2, such as delete
export type Operation = {
  name: string;
  permRoute?: string; //e
  action:
    | (() => Promise<void>) //e
    | ((index: number) => Promise<void>) //e
    | (() => void) //e
    | ((index: number) => void);
};
